package com.xinqi.modules.sys.rotation.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.common.core.enums.RotationImagePositionEnum;
import com.xinqi.common.core.enums.RotationImageTypeEnum;
import com.xinqi.common.satoken.utils.LoginHelper;
import com.xinqi.modules.sys.rotation.dto.req.RotationImageQueryDTO;
import com.xinqi.modules.sys.rotation.dto.rsp.RotationImageResultDTO;
import com.xinqi.modules.sys.rotation.service.RotationImageService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * WEB -- 系统轮播图
 *
 * @author: yyzhenn
 * @date: 2023/04/23
 */
@RestController
@RequestMapping("/web/rotation-image")
@RequiredArgsConstructor
public class RotationImageWebController {
    private final RotationImageService rotationImageService;

    @Operation(summary = "轮播图位置-枚举列表")
    @GetMapping("/position/list")
    public R<List<Map<String, String>>> positionList() {
        return R.data(RotationImagePositionEnum.getSelectList(RotationImageTypeEnum.PC.getCode()));
    }

    @Operation(summary = "系统轮播图-列表")
    @PostMapping("/list")
    public R<List<RotationImageResultDTO>> list(@RequestBody RotationImageQueryDTO dto) {
        return R.data(rotationImageService.listByPc(LoginHelper.getXqLoginUser(), dto));
    }

    @Operation(summary = "系统轮播图-详情")
    @GetMapping("/info/{id}")
    public R<RotationImageResultDTO> info(@PathVariable("id") Long id) {
        return R.data(rotationImageService.findById(id));
    }

}
